//
//  LzwWorkTableCell.m
//  NewHalfsugar
//
//  Created by 刘志武 on 16/1/2.
//  Copyright © 2016年 刘志武. All rights reserved.
//

#import "LzwWorkTableCell.h"
#import "UIImageView+WebCache.h"
#import "LzwBaseImageView.h"
#import "LzwBaseLable.h"

@interface LzwWorkTableCell ()

@property (nonatomic, retain) LzwBaseImageView *myImageWork;
@property (nonatomic, retain) LzwBaseImageView *myImageWork1;

@property (nonatomic, retain) LzwBaseLable *myLableWork;
@property (nonatomic, retain) LzwBaseLable *myLableWork1;



@end

@implementation LzwWorkTableCell

-(void)dealloc{
    [_myImageWork release];
    [_myImageWork1 release];
    [_myLableWork release];
    [_myLableWork1 release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self creatWork];
    }
    return self;
}

- (void)creatWork{
    
    //图片
    self.myImageWork = [[LzwBaseImageView alloc]initWithFrame:CGRectMake(3 * WIDTH, 3 * WIDTH, 370 * WIDTH, 180 * WIDTH)];
    self.myImageWork.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.myImageWork];
    
    //喜爱图片
    self.myImageWork1 = [[LzwBaseImageView alloc]initWithFrame:CGRectMake((375 - 20) / 2 - 70 * WIDTH, 230 * WIDTH, 20 * WIDTH, 20 * WIDTH)];
    self.myImageWork1.image = [UIImage imageNamed:@"love.png"];
    [self.contentView addSubview:self.myImageWork1];
    
    //描述
    self.myLableWork = [[LzwBaseLable alloc]initWithFrame:CGRectMake(2 * WIDTH, 185 * WIDTH, 369 * WIDTH, 45 * WIDTH)];
    self.myLableWork.textColor = [UIColor lightGrayColor];
    self.myLableWork.font = [UIFont systemFontOfSize:16 * WIDTH];
    self.myLableWork.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.myLableWork];
    
    //喜爱人数
    self.myLableWork1 = [[LzwBaseLable alloc]initWithFrame:CGRectMake((375 - 20) / 2 - 50 + 5 * WIDTH, 230 * WIDTH, 60 * WIDTH, 20 * WIDTH)];
    self.myLableWork1.textColor = [UIColor lightGrayColor];
    self.myLableWork1.font = [UIFont systemFontOfSize:16 * WIDTH];
    self.myLableWork1.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.myLableWork1];
    
    [_myImageWork release];
    [_myImageWork1 release];
    [_myLableWork release];
    [_myLableWork1 release];
}

- (void)setModleWork:(LzwWorkModle *)modleWork{
    
    if (_modleWork != modleWork) {
        [_modleWork release];
        _modleWork = [modleWork retain];
    }
    
    self.myLableWork.text = self.modleWork.title;
    self.myLableWork1.text = self.modleWork.likes;
    
    NSURL *url = [NSURL URLWithString:self.modleWork.pic];
    
    [self.myImageWork sd_setImageWithURL:url placeholderImage:nil];
    
    
}


@end
